<%@ page language="java" import="java.util.*" import="java.sql.*" import = "orm.*"  pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
User user= (User)session.getAttribute("Teacher");
if(user==null)
   response.sendRedirect("../index.jsp");
    
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href = <%=basePath%> />
<title>监控中心</title>
<link href="css/sStyles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#help {
	background-image: url(../images/main.png);
	position:relative;
	background-repeat: no-repeat;
	height: 620px;
	width: 300px;
	font-family: "华文新魏";
	font-size: 24px;
	color: #000000;
	overflow:hidden;
	visibility: visible;
}
#
body,td,th {
	color: #000;
}
body,td,th {
	color: #000;
}
td {
	font-size: small;
}
</style>
<script language="javascript" src="js/AjaxRequest.js"></script>
<script language="javascript">
    window.setInterval("showContent();",1000); 
    window.setInterval("showOnline();",10000); 
    function showOnline(){
	    var loader=new net.AjaxRequest("testMonitor.do?action=online&nocache="+new Date().getTime(),deal_online,onerror,"GET");
    }
    function showContent(){
	    var loader1=new net.AjaxRequest("testMonitor.do?action=getMsg&nocache="+new Date().getTime(),deal_content,onerror,"GET");
        }
    function onerror(){
	   // alert("很抱歉，服务器出现错误.");
    }
    function deal_online(){
	    online.innerHTML=this.req.responseText;
}
    function deal_content(){
	   var returnValue=this.req.responseText;
	   var h=returnValue.replace(/\s/g,"");	
	   if(h!="error"){
		   content.innerHTML=returnValue;
	    }
    }
      //控制是否滚屏
    function checkScrollScreen(){
		document.getElementById("content").style.overflow='hidden';
		document.getElementById('content').scrollTop = document.getElementById('content').scrollHeight*2;	//当聊天信息超过一屏时，设置最先发送的聊天信息不显示
	    setTimeout('checkScrollScreen()',500);
    }
    window.onload=function(){
	     checkScrollScreen();				//当页面载入后控制是否滚屏
	     showContent();						//当页面载入后显示聊天内容
	     showOnline();						//当页面载入后显示在线人员列表
      }
    function send(){	//验证聊天信息并发送
		if(chat.receiver.value==""){
			alert("请选择发送对象！");return false;
		}
		if(chat.sMsg.value==""){
			alert("发送信息不可以为空！");chat.sMsg.focus();return false;
		}
		var param="from="+chat.receiver.value+"&sMsg="+chat.sMsg.value; 
		var loader=new net.AjaxRequest("testMonitor.do?action=sendMsg",deal_send,onerror,"POST",param);
		document.getElementById("sMsg").value='';
		return true;

	}
    function deal_send(){
        content.innerHTML=this.req.responseText;
		document.getElementById('content').scrollTop = document.getElementById('content').scrollHeight*2;	//当聊天信息超过一屏时，设置最先发送的聊天信息不显示
	}	
</script>
</head>

<body>
	<!-- CONTAINER START -->
<div id="apDiv1"></div>
<div id = "container">
<!-- HEADER START -->
<div id = "top">
        	<div id = "navigation">
            	<html:link page="/teacher/teacher.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
                <html:link page="/teacher/notice.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
                <html:link action="manageQuestions.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;题库</html:link>
                <html:link action="manageKnowledges.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;知识点</html:link>
                <html:link action="manageTemplates.do?action=startManagement" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;试卷模板</html:link>
                <html:link action="gradeManagement.do?action=startMana" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;成绩管理</html:link>
                <html:link page="/teacher/studentMana.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;学生管理</html:link>
            </div>
  </div>
        <!-- HEADER END -->
        
    <!-- LOGIN START -->
<div id="help">
  <table width="299" height="100" border="1">
  <caption>
    状态说明
  </caption>
  <tr>
    <th scope="col"><strong>考生正在考试</strong></th>
    <th><img src="images/on.png" width="50" height="50" />&nbsp;</th>
  </tr>
  <tr>
    <td align="center"><strong>考生已经交卷</strong></td>
    <td align="center"><img src="images/done.png" width="50" height="50" />&nbsp;</td>
  </tr>
  <tr>
    <td height="76" align="center"><strong>考生尚未参加考试</strong></td>
    <td align="center"><img src="images/off.png" width="50" height="50"/>&nbsp;</td>
  </tr>
</table>
<form name="chat" method="post" action="" ><div align="left"> 
   </div>
     <table>
     <tr>
            消息内容:
            <td id="content"></td>
       
     </tr>
     <tr>
          <td>
           接收者：<input name="receiver" type="text"/>
          </td>
      </tr>
      <tr>
         <td>
          内容 ：<textarea name="sMsg" rows="5" cols="32"></textarea></td>
      </tr>
      <tr>
         <td height="79" align="center">
         <input type="button" name="sendMsg" value="发送" onclick="return send()" /></td>
      </tr>
      </table>
</form>
  </div>
<!-- LOGIN END -->
      <div id="main">
        <table width="721" border="1" id="online">
    </table>
      </div>
        
<!-- FOOTER START -->
<div id = "footer" ></div>
<!-- FOOTER END -->
</div>
    <!-- CONTAINER END -->
</body>
</html>
